/*
Copyright (C) 2011 by Gary Wilber

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

// THIS IS NOT AN OFFICAL API. I'm not affiliated with Google in any way.

// If you don't know whats going on check out http://code.google.com/p/steam-chat-relay/

#ifndef _GOOGLEVOICE_H_
#define _GOOGLEVOICE_H_

#include <string>
#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <stdio.h>
#include <vector>

#define CURL_STATICLIB
#include "curl.h"

using namespace std;

struct sms_data
{
	string id;
	string phoneNumber;
	string message;
	string time;
};

typedef vector<sms_data> sms_vector;

class GoogleVoice
{

	public:
		GoogleVoice(string username, string password);
		~GoogleVoice();

		bool Login();

		bool SendSMS(string number, string message);
		sms_vector GetNewSMS();
		bool MarkSMSRead(string msg_id);
		bool DeleteSMS(string msg_id);

		int curlWriter(char *data, size_t size, size_t nmemb, string *buffer); 
		static int staticCurlWriter(char *data, size_t size, size_t nmemb, string *buffer, void *f);

	private:
		CURL *curl;

		string username;
		string password;
		string cookieFile;
		string rnr_se;

		bool loggedIn;

		char curlErrorBuffer[CURL_ERROR_SIZE];
		string curlData;

};

#endif
